package com.cocotingo.snail.template.models;

import java.util.LinkedList;
import java.util.List;

public class LayoutFactorPair {
	
	private final int viewIndex;
	private final LayoutFactorNode factor1;
	private final LayoutFactorNode factor2;
	private final List<LayoutFactorPair> dependency;
	
	LayoutFactorPair(int viewIndex, LayoutFactorNode factor1, LayoutFactorNode factor2) {
		this.viewIndex = viewIndex;
		this.factor1 = factor1;
		this.factor2 = factor2;
		dependency = new LinkedList<LayoutFactorPair>();
	}
	
	public int getViewIndex() {
		return viewIndex;
	}
	
	public LayoutFactorNode getFactor1() {
		return factor1;
	}
	
	public LayoutFactorNode getFactor2() {
		return factor2;
	}
	
	public boolean isHorizentalPair() {
		return factor1.isHorizentalFactor();
	}
	
	public boolean isVerticalPair() {
		return factor1.isVerticalFactor();
	}
	
	void addDependency(LayoutFactorPair pair) {
		if (pair != null && !dependency.contains(pair))
			dependency.add(pair);
	}
	
	void removeDependency(LayoutFactorPair pair) {
		dependency.remove(pair);
	}
	
	int dependencyCount() {
		return dependency.size();
	}

}
